package com.imay.live.fragment.user;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.imay.base.helper.ActivityHelper;
import com.imay.live.R;
import com.imay.live.activity.user.LoginActivity;
import com.imay.live.activity.user.ResigterActivity;
import com.imay.live.fragment.BaseRequestFragment;

/**
 * Created by Administrator on 2017/8/7 0007.
 */

public abstract class UserBaseFragment extends BaseRequestFragment {

    public static final int REQUEST_LOGIN = 10;
    public static final int REQUEST_RESIGTER = 11;

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (useDynamicTitleBar()) {
            getTitleBar().setTitleColor(getResources().getColor(R.color.text_20));
            getTitleBar().setLeftImageResource(R.mipmap.btn_04xinxi);
            int margin = getResources().getDimensionPixelOffset(com.imay.R.dimen.margin_side);
            getTitleBar().getLeftImageView().setPadding(margin, 0, margin, 0);
            getTitleBar().setBackgroundColor(Color.WHITE);
        }
    }

    /**
     * 跳转到登录界面
     */
    protected synchronized void toLogin() {
        if (ActivityHelper.getInstance().getCurrentActivity() instanceof LoginActivity) {
            return;
        }
        LoginActivity.startActivityForResult(getActivity(), REQUEST_LOGIN);
    }

    /**
     * 跳转至注册界面
     */
    protected void toResigter() {
        ResigterActivity.startActivityForResult(getActivity(), ResigterActivity.STATUS_REGISTER, REQUEST_RESIGTER);
    }
}
